<?php

/**
 * club actions.
 *
 * @package    makethetouch
 * @subpackage club
 * @author     Sebastien Chassande-Barrioz
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class clubActions extends sfActions {

    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request) {
        $this->redirect($this->getDefaultSubMenu());
    }

    public function getDefaultSubMenu() {
        $person = $this->getUser()->getPerson();
        if ($person == null) {
            return menu::CLUB__FIND;
        } else if ($person->hasAClub()) {
            return menu::CLUB__MYCLUB;
        } else {
            return menu::CLUB__NEWCLUB;
        }
    }

    public function executeClub_find(sfWebRequest $request) {
        $this->getUser()->getMenu()->setMenuEntry(menu::CLUB, menu::CLUB__FIND);
        $this->setTemplate('find');
    }

    public function executeClub_myclub(sfWebRequest $request) {
        $this->getUser()->getMenu()->setMenuEntry(menu::CLUB, menu::CLUB__MYCLUB);
        $this->setTemplate('myclub');
    }

    public function executeClub_newclub(sfWebRequest $request) {
        $this->getUser()->getMenu()->setMenuEntry(menu::CLUB, menu::CLUB__NEWCLUB);
        $this->setTemplate('new');

        $this->form = new ClubForm();
    }

    public function executeCreate(sfWebRequest $request) {
        //TODO
        $this->redirect(menu::CLUB__MYCLUB);
    }

}
